<template>
  <div class="login-wrapper">
    <div id="login">
      <el-form :model="loginForm" :rules="loginRules">
        <h2>登录</h2>
        <el-form-item prop="username">
          <el-input v-model="loginForm.username" name="username" placeholder="请输入用户名" auto-complete="on"></el-input>
        </el-form-item>

        <el-form-item prop="password">
          <el-input v-model="loginForm.password" name="password" placeholder="请输入密码" auto-complete="on"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="handleLogin">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  name: 'login',
  data () {
    return {
      loginForm: {
        username: '',
        password: ''
      },
      loginRules: {
        username: [
          {
            required: true,
            message: '请输入用户名',
            trigger: 'blur'
          }
        ],
        password: [
          {
            required: true,
            message: '请输入密码',
            trigger: 'blur'
          }
        ]
      }
    }
  },
  methods: {
    handleLogin () {
      this.$router.push('/')
    }
  }
}
</script>
<style scoped>
  .login-wrapper{
    height: 100%;
    display: flex;
  }
  .el-input {
    width:300px;
  }
  #login {
    align-self: center;
    width:300px;
    margin:0 auto 150px;
    padding:20px;
    text-align:center;
    border:1px solid #409eff;
    border-radius: 10px;
    box-shadow: 6px 6px 15px #409eff;
  }
</style>
